//
//  SearchSceneryCollectionViewCell.m
//  BTRIP
//
//  Created by Rain on 15/11/19.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "SearchSceneryCollectionViewCell.h"
#import "SearchOtherModel.h"
#import <SDWebImageManager.h>
#import <UIImageView+WebCache.h>

@interface SearchSceneryCollectionViewCell ()

@property (nonatomic, retain) UILabel *name;

@property (nonatomic, retain) UIImageView *imageView;

@end

@implementation SearchSceneryCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        self.imageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.imageView];
        [self.imageView release];
        
        self.name = [[UILabel alloc] init];
        self.name.textAlignment = NSTextAlignmentCenter;
        self.name.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.name];
        [self.name release];
        
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.imageView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height - 15 * SWIDTH);
    self.name.frame = CGRectMake(0, self.frame.size.height - 15 * SWIDTH, self.frame.size.width, 15 * SWIDTH);
    
}

- (void)setSearchModel:(SearchOtherModel *)searchModel {
    
    if (_searchModel != searchModel) {
        [_searchModel release];
        _searchModel = [searchModel retain];
    }
    
    self.name.text = _searchModel.name;
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:_searchModel.image_url] placeholderImage:[UIImage imageNamed:@"background"]];
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
